<?php
class User_Form_ScheduleSelect extends Zend_Form {

	protected $_schedule;
	protected $_submit;

	public function init() {
		$this->_schedule = new Zend_Form_Element_Select('schedule');
		$this->_schedule->setLabel('Choosen schedule');

		$this->_submit = new Zend_Form_Element_Submit('submit');
		$this->_submit->setLabel('Go');
		$this->addElements(array($this->_schedule, $this->_submit));
	}

	public function bindData($schedules) {
		if (isset($schedules)) {
			$data = array();
			foreach ($schedules as $schedule) {
				$data[$schedule->_sid] = 'From '.$schedule->_fromdate.' to '.$schedule->_todate;
			}
			$this->_schedule->setMultiOptions($data);
		}

	}

	public function populateData(Admin_Model_Schedule $schedule) {
		if (isset($schedule->_sid)) {
			$this->_schedule->setValue($schedule->_sid);
		}
	}
}